/* 
* @Author: Administrator
* @Date:   2014-04-21 11:55:47
* @Last Modified by:   Administrator
* @Last Modified time: 2014-04-27 14:02:25
*/

$(document).ready(function(){
    $('.userInfoNav li').click(function() {
    	var c=$(this).index();
    	$(this).addClass('on').siblings('li').removeClass('on');
    	$('.userInfoBox').eq(c).show().siblings('.userInfoBox').hide();
    });
    //异步收货
    $('.recevied_goods').click(function() {
    	var obj=$(this);
    	var oid=obj.attr('oid');
    	var num=$('.recevied_num').html()-1;
    	$.ajax({
			url 	: recevied_goods_url,
			type 	: 'POST',
			dataType: 'json',
			data 	: {'oid':oid},
			success : function(data){
				if(!data.state){
					alert(data.message);
					return false;
				}else{
					alert(data.message);
					$('.recevied_num').html(num);
					obj.parents("li").remove();
					return true;
				}
			}
		})
    });
    //异步显示订单中的商品
    $('.show_ordergoods').click(function() {
    	var obj=$(this);
    	var oid=obj.attr('oid');
    	$.ajax({
			url 	: show_ordergoods_url,
			type 	: 'POST',
			dataType: 'json',
			data 	: {'oid':oid},
			success : function(data){
				popWin('comment');
				$('#goods_box').empty();
				$.each(data, function(index, val) {
					$('#goods_box').prepend("<div class='order_info_one2'><dl><dt><img width='32px' height='32px' src='"+ROOT+"/"+val.gthumb_img+"'></dt><p><a target='_blank' href='"+goods_url+val.qm_goods_gid+"'>"+val.gname+"</a></p></dl><span class='order_info_danjia'>￥"+val.lprice+"</span><span class='order_info_num'>"+val.lnumber+"</span><span class='order_info_xiaoji'>￥"+val.lmoney+"</span><span class='order_info_comment'><a target='_blank' href='"+goods_url+val.qm_goods_gid+"'>点击评价</a></span></div>");
				});
			}
		})
    });
});